package f.admin.bo.service;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import f.admin.bo.entity.BOModule;
import f.orm.dao.BaseDao;

public class BOModuleDBService extends BaseDao {

	public void insert(BOModule boModule) throws Exception {
		String sql = "insert into T_DEP_BO_MODULE(ID,NAME,CREATE_TIME)" +
					" values(" +
							"'" + boModule.getId() + "'," +
							"'" + boModule.getName() + "'," +
							"NOW())";
		executeUpdate(sql, null);
	}
	
	public List<BOModule> getList() {
		List<BOModule> boModuleList = new ArrayList<BOModule>();
		try {
			getConnection();
			String sql = "select * from T_DEP_BO_MODULE order by CREATE_TIME desc";
			ResultSet rs = executeQuery(sql, null);
			while(rs.next()) {
				BOModule boModule = new BOModule();
				boModule.setId(rs.getString("ID"));
				boModule.setName(rs.getString("NAME"));
				boModule.setCreateTime(rs.getDate("CREATE_TIME"));
				boModuleList.add(boModule);
			}
		} catch(Exception e) {
			e.printStackTrace();
		} finally {
			close();
		}
		return boModuleList;
	}
}
